﻿using System;
using System.Collections.Generic;
using System.Linq;
using Autodesk.Revit.DB;

namespace HYRevitCode.FaceCalculateUtility
{
	public class ElementFaceCalculateManager : BaseCalculateManager
	{
		public List<ElementPacker> LstElementPacker
		{
			get
			{
				return this.m_lstElementPacker;
			}
			private set
			{
				this.m_lstElementPacker = value;
			}
		}

		public ElementFaceCalculateManager(List<Element> inputElement, uint nXDirectionNumber = 1u, uint nYDirectionNumber = 1u, uint nZDirectionNumber = 1u)
		{
			if (inputElement == null)
			{
				inputElement = new List<Element>();
			}
			inputElement = inputElement.Distinct<Element>().ToList<Element>();
			this.LstElementPacker = (from n in inputElement
			select new ElementPacker(n)).ToList<ElementPacker>();
			base.LstAllInputFace = new List<PlanarFacePacker>();
			foreach (ElementPacker elementPacker in this.LstElementPacker)
			{
				base.LstAllInputFace.AddRange(elementPacker.ThisLstFace);
			}
			BaseCalculateManager.ResetNumber(ref nXDirectionNumber);
			BaseCalculateManager.ResetNumber(ref nYDirectionNumber);
			BaseCalculateManager.ResetNumber(ref nZDirectionNumber);
			this.m_useFaceGroupHandler = new FaceGroupHandler(this.LstElementPacker.Cast<BasePacker>().ToList<BasePacker>(), (int)nXDirectionNumber, (int)nYDirectionNumber, (int)nZDirectionNumber);
		}

		private List<ElementPacker> m_lstElementPacker;
	}
}
